<?php
ini_set("display_errors", "On");
error_reporting(E_ALL);

// 引入数据库连接文件
require_once 'coon/connection.php';

$id = $_POST['deleteID'];


$querySql = "select id,saveAddress,name from greeting_card where id = '$id'";
$result = mysqli_query($GLOBALS['conn'], $querySql);

$row = mysqli_fetch_array($result);

$path = $row['saveAddress'];
$fileName = $row['name'];

$now = date('Y-m-d H:i:s', time());
$addSql = "UPDATE greeting_card SET is_delete = 1 where id = '$id'";

if (file_exists($path . $fileName)) {
	if (mysqli_query($GLOBALS['conn'], $addSql) && unlink($path . $fileName)) {
		echo "
            <script>
                alert('删除成功！');
                window.location.href=document.referrer;
            </script>
        ";
	} else {
		echo "
            <script>
                alert('删除失败！');
                history.back();
            </script>
        ";
	}
}



